import React, { useEffect, useState } from "react";
import http from "../../api/http";
import { List, Switch } from "antd-mobile";
import { ProductCard, Tag, Button } from "react-vant";
function Index() {
  const [HomeList, setHomeList] = useState([]);

  const getHomeList = async () => {
    const res = await http.get("/api/list");
    const { code, data } = res.data;
    console.log(data);
    if (code === 200) {
      setHomeList(data);
    }
  };
  useEffect(() => {
    getHomeList();
  }, []);
  return (
    <div>
      {/* 3-1、正确使用useEffect发起http请求获取首页出行资讯列表
3-2、正确使用useState定义出行资讯列表数据
3-3、遍历渲染出行资讯列表 */}
      {HomeList?.map((item, ind) => (
        <ProductCard 
          key={ind}
          price={item.price}
          desc={item.title}
          title={item.id}
           title1={item.date}
          thumb={item.image}
        />
      ))}
    </div>
  );
}

export default Index;
